﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Runtime.Serialization;
using RStein.PosterousReader.Common.ViewModelsHelpers;

namespace RStein.PosterousReader.WP.ViewModels.ViewObjects
{
  [DataContract]
  public abstract class ViewObjectBase : PropertyNotificationBase
  {
    private int? m_id;

    public ViewObjectBase()
    {
      Id = null;
    }
    
    [DataMember]
    public int? Id
    {
      get
      {
        return m_id;
      }

      set
      {
        m_id = value;
        RaisePropertyChangedEvent(() => Id);
      }
    }


    public override bool Equals(object other)
    {
      if (ReferenceEquals(null, other))
      {
        return false;
      }
      if (ReferenceEquals(this, other))
      {
        return true;
      }
      if (other.GetType() != GetType())
      {
        return false;
      }
      
      var otherViewBase = other as ViewObjectBase;
      return otherViewBase.Id == Id;

    }

    public override int GetHashCode()
    {
      return (int) Id;
    }


  }

}
